package com.jspeed.dialogeservice.client;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.jspeed.dialogeservice.DialogeService;

public class Client {

	public static void main(String[] args) throws NamingException {
		testEJB();
	}

	public static void testEJB() {
		try {
			final Context context = getInitialContext();
			Object o = context.lookup("DialogeServiceBean/remote");
			DialogeService providerService = (DialogeService) o;
			providerService.getProvider(null);
			
			System.out.println("running test");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	public static Context getInitialContext() throws NamingException {
		Properties properties = new Properties();

		properties.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"org.jnp.interfaces.NamingContextFactory");
		properties.put(InitialContext.PROVIDER_URL, "jnp://localhost:1099");
		properties.put(InitialContext.URL_PKG_PREFIXES,
				"org.jboss.naming:org.jnp.interfaces");

		InitialContext iniCtx = new InitialContext(properties);
		return iniCtx;
	}
}